package com.studentmanagement.ui;

import com.studentmanagement.model.User;

import javax.swing.*;
import java.awt.*;

public class HomePanel extends JPanel {
    private User currentUser;

    public HomePanel(User user) {
        this.currentUser = user;
        initComponents();
    }

    private void initComponents() {
        setLayout(new BorderLayout(10, 10));
        setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));

        JLabel welcomeLabel = new JLabel("欢迎您，" + currentUser.getUsername() + "!");
        welcomeLabel.setFont(new Font("微软雅黑", Font.BOLD, 24));
        welcomeLabel.setHorizontalAlignment(SwingConstants.CENTER);

        JLabel roleLabel = new JLabel("您的角色: " + currentUser.getRole());
        roleLabel.setFont(new Font("微软雅黑", Font.PLAIN, 16));
        roleLabel.setHorizontalAlignment(SwingConstants.CENTER);

        JTextArea infoArea = new JTextArea();
        infoArea.setFont(new Font("微软雅黑", Font.PLAIN, 14));
        infoArea.setText("这里是学生信息管理系统的首页。\n\n" +
                         "您可以使用左侧的菜单栏来浏览和操作系统功能。\n\n" +
                         "更多功能正在开发中，敬请期待！");
        infoArea.setEditable(false);
        infoArea.setOpaque(false);
        infoArea.setLineWrap(true);
        infoArea.setWrapStyleWord(true);
        infoArea.setBorder(BorderFactory.createEmptyBorder(20,0,0,0));
        
        JPanel centerPanel = new JPanel(new BorderLayout());
        centerPanel.add(roleLabel, BorderLayout.NORTH);
        centerPanel.add(new JScrollPane(infoArea), BorderLayout.CENTER);

        add(welcomeLabel, BorderLayout.NORTH);
        add(centerPanel, BorderLayout.CENTER);
        
        // 您可以在此处根据用户角色或其他信息添加更多组件
        // 例如，为管理员显示仪表盘摘要，或为学生/教师显示即将开始的课程等。
    }
} 